import {GLTFLoader} from 'three/examples/jsm/loaders/GLTFLoader'
import {scene} from '../../scene'
import * as THREE from 'three'
import { modifyCityMaterial } from './modifyCityMaterial'
import { FlyLine } from '../fly-line'
import { FlyLineShader } from '../fly-line/flyLinerShader'
export function createCity(){

    const gltfLoader = new GLTFLoader()
    gltfLoader.load('./city2.glb',(gltf)=>{
     
      
       
        gltf.scene.traverse((item:any)=>{
          
        
            if(item.type==='Mesh'){
                const cityMaterial = new  THREE.MeshBasicMaterial({
                    color:new THREE.Color(0x0c0e33)
                })
              
                item.material = cityMaterial
                modifyCityMaterial(item)
                if (item.name == "Layerbuildings") {
                    // const meshLine = new MeshLine(item.geometry);
                    // const size = item.scale.x;
                    // meshLine.mesh.scale.set(size, size, size);
                    // scene.add(meshLine.mesh);
                  }
            }
            // if(item.name ==='Layertopography'){
            //     console.log(item.position.y,'item.position.y')
            //     // item.position.y = 0.5
            // }
           
        })
        scene.add(gltf.scene)
        // 添加飞线
        const flyLine = new FlyLine();
        if(flyLine.mesh){
            scene.add(flyLine.mesh);
        }
        // 添加着色器飞线
        const flyLineShader= new FlyLineShader({ x:5, z: 0 })
        if(flyLineShader.mesh){
           
            scene.add(flyLineShader.mesh)
        }

        

    })
}